<include file="Public:head" />


<div class="table_box">
  <!-- 筛选 -->
  <!-- <form class="layui-form" id="search" action="__APP__/admin/list_" m     ethod="get" style="margin-bottom: 20px;">
      <div class="layui-input-inline">
        <input type="text" name="username1" lay-verify="username1" autocomplete="off" placeholder="账号搜索" class="layui-input" style="width:200px;" value="{$username1}">
      </div>
      <div class="layui-input-inline">
        <select name="group_id_" id="group_id_">
          <option value="">分组查询</option>
          <foreach name="groupname" key="k" item="v">
            <option value="{$v.id}">{$v.groupname}</option>
          </foreach>
        </select>    

      </div>
      <script type="text/javascript">
        $("#group_id_").val("{$group_id_}");
        /*function fomrReset()
        {
            document.getElementById("search").reset();
        }*/
        
      </script>

      <div class="layui-input-inline" style="margin-left: 10px;">
        <button class="layui-btn " type="submit">搜索</button>
        <button class="layui-btn layui-btn-primary" onclick="resetAll()"   style="margin-left: 00px;">重置</button>
      </div>
      
  </form> -->

  <!-- 表格 -->
  <table class="layui-table layui-table-wen" >
    <colgroup>
      <col width="100">
      <col>
      <col>

      <col>

      <col>
      <col>
      <col width="180">
    </colgroup>
    <thead>
      <tr>
        <th>ID</th>
        <th>First name</th>
        <th>Last name</th>

        <th>email</th>
        <th>phone</th>
        <th>内容</th>
        <th>时间</th>
        
       
      </tr> 
    </thead>
    <tbody>
      <foreach name="list" key="k" item="v">
      <tr>
        <td>{$v.id}</td>
        <td>{$v.fname}</td>
        <td>{$v.lname}</td>
        
        <td>{$v.email}</td>
        <td>{$v.phone}</td>
        <td>{$v.contant}</td>
        <td>{$v.ctime}</td>
        

       
      </tr>

      </foreach>
      
    </tbody>
  </table>
  {$page}

</div>

<include file="Public:foot" />












<!-- ---------------------------------------------------------------- -->










<script>
//模态窗
function doedit (type,id,username,des,status,group_id) {
  if(type == 1){
    var txt = '添加'; 
  }else{
    var txt = '编辑'; 
  }
  layui.use(['layer','form'], function() {
    var form = layui.form;
    var layer = layui.layer;

    layer.open({
      type: 1,
      title: txt,
      area: ['550px', '400px'] ,
      shadeClose: true,
      content: $('#box').html()
    })

    $('#username').val(username);
    $('#des').val(des);
    $('#status').val(status);
    $('#group_id').val(group_id);
    $('.editId').val(id);
    $('.typeId').val(type);

    form.render();//渲染
  })
}

//确定-提交
function sub(){
  var username = $('#username').val();
  var status = $('#status').val();
  var group_id = $('#group_id').val();

  if(username == ''){
      layer.msg('账号不能为空',{
        time:900  ,           //时间
      });
      return false;
  }
  if(group_id == null){
      layer.msg('账号分组不能为空',{
        time:900  ,           //时间
      });
      return false;
  }
  if(status == null){
      layer.msg('状态不能为空',{
        time:900  ,           //时间
      });
      return false;
  }
  
  $.ajax({
      type:"get",
      url:"__APP__/admin/add_edit",
      data:$("#add_edit").serialize(),

      success:function(data){

        returnInfo(data);

      }        
  })//ajax结束
}
//取消-提交

//删除
function del(id){
  layer.confirm('确定永久删除这个账号吗？', {
    btn: ['确定'], //按钮
    title: '系统提示',
    shadeClose: true
  }, function(){  //确定
    $.ajax({
        type:"get",
        url:"__APP__/admin/del?id="+id,
        

        success:function(data){
          console.log(data);
          // alert(data);
          returnInfo(data);

        }        
    })//ajax结束
  })


}

</script>










<!-- ---------------------------------------------------------------- -->











<script id="box">
  <style>
    .layui-input-item{
      margin-bottom: 15px;
    }
  </style>
  <form class="layui-form" id="add_edit" action="" style="margin:15px;">
    <!-- 隐藏域 -->
    <input type="hidden" name="id" class="editId">
    <input type="hidden" name="type" class="typeId">
    <!-- 文本输入 -->
    <div class="layui-form-item" style="">
      <label class="layui-form-label"><span style="color:red">*</span> 账号</label>
      <div class="layui-input-inline">
        <input type="text" id="username" name="username" lay-verify="username" autocomplete="off" placeholder="请输入账号名" class="layui-input" >
      </div>
    </div>
    <!-- 下拉选框 -->
    <div class="layui-form-item">
      <label class="layui-form-label"><span style="color:red">*</span> 账号分组</label>
      <div class="layui-input-inline">
        <select name="group_id" id="group_id">
          
          <foreach name="groupname" key="k" item="v">
            <option value="{$v.id}">{$v.groupname}</option>
          </foreach>
        </select>
      </div>
    </div>  
    <!-- 下拉选框 -->
    <div class="layui-form-item">
      <label class="layui-form-label"><span style="color:red">*</span> 状态</label>
      <div class="layui-input-inline">
        <select name="status" id="status">
          <option value="1">开启</option>
          <option value="0">关闭</option>
        </select>
      </div>
    </div> 
    <!-- 普通文本域 -->  
    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">说明</label>
      <div class="layui-input-block">
        <textarea placeholder="请输入内容" name='des' class="layui-textarea" style="width:340px" id="des"></textarea>
      </div>
    </div>
    <!-- 按钮 -->
    <div class="layui-form-item" style="margin:20px auto;width:150px;">
      <a class="layui-btn" onclick="sub()">确定</a>
      <a class="layui-btn layui-btn-primary" onclick="close_()">取消</a>
    </div>
  </form>
</div>
</script>